You can specify a callback procedure as the fourth parameter to the SndNewChannel function. The callback procedure executes whenever the Sound Manager processes a callBackCmd command for the channel.
A callback procedure has the following syntax:
PROCEDURE MyCallbackProcedure (theChan: SndChannelPtr;
theCmd: SndCommand);
The Sound Manager executes the callback procedure associated with a sound channel whenever it processes a callBackCmd command for the channel. You can use a callback procedure to set a global flag that alerts the application that it must dispose of the sound channel. Or, you can use a callback procedure so that your application can synchronize a series of sound commands with other actions.
A callback procedure is called at interrupt time. It must not make any calls to the Memory Manager, either directly or indirectly. If your callback procedure needs to access your application's global variables, you must ensure that register A5 contains your application's A5. (You can use the userInfo field of the sound channel pointed to by the theChan parameter or the param2 field of the sound command specified in the theCmd parameter to pass that value to your callback procedure.)
Because a callback procedure is called at interrupt time, it must preserve all registers other than A0-A1 and D0-D2.
For information on how you can use callback procedures when playing sound asynchronously, see "Using Callback Procedures" .
| Previous | Chapter contents | Chapter top | Section top | Next |